export const setStorage = (name, value) => {
  if (!name) return;

  if (typeof value != "string") {
    value = JSON.stringify(value);
  }
  window.sessionStorage.setItem(name, value);
};

export const getStorage = (name) => {
  if (!name) return;

  let item = window.sessionStorage.getItem(name);
  if (item) {
    try {
      // 尝饰json字符串转对象
      item = JSON.parse(item);
    } catch (err) {
      item = item;
    }
    return item;
  } else {
    return null;
  }
};

export const removeStorage = (name) => {
  if (!name) return;
  window.sessionStorage.removeItem(name);
};
